let config = require("./config.js");

var login = {};
login.getUserId = function (){
    return config.getKey("user_id")
}

login.deviceLogin = function (){
    
    try {
        http.__okhttp__.setTimeout(50000);//
        var Url = "http://axie_tool_manage.webl.vip/device/login";
        var result = http.post(Url, {
            headers: {
                "Content - Type": "application/json;charset=UTF-8" 
            },
            device_id: device.fingerprint,
            android_id:device.getAndroidId(),
            user_id:config.getKey("user_id"),
        })
        if (result.body.json().code==0){
            //
            var Expiration = new Date(result.body.json().data.user.Expiration).getTime()
            var Now = new Date().getTime()
            if(!result.body.json().data.user.Enable){
                toast("用户已被禁用，请联系qq97020075");
            }else if(!result.body.json().data.device.Enable){
                toast("设备已被禁用，请联系qq97020075");
            }else if(Expiration <Now){
                toast("已到期，请联系qq97020075");
            }else{
                return 
            }
        }else{
            toast("信息出错，即将推出");
        }
    } catch(e) {
        toast(e);
        toast("网路出错，请检查，即将推出");
    }
    engines.stopAll();
    exit() 
}
module.exports = login;
